use rand::Rng;
use std::io;
fn main() {
    println!("Guess number!");
    let secret_number:u32 = rand::rng().random_range(1..101);
    loop {
        // 获取用户输入
        let mut guess = String::new();
        io::stdin().read_line(&mut guess).unwrap();

        let guess_number:u32 =  match guess.trim().parse(){
            Ok(num)=>num,
            Err(_err)=>continue,
        };
        // 判断大小
        println!("you guessed:{}",guess_number);
        if guess_number > secret_number {
            println!("too big");
        } else if guess_number < secret_number {
            println!("too small");
        }else{
            println!("you win");
            break
        }



    }
}
